#include <iostream>
#include <cstring>
#include <queue>
#include <vector>
using namespace std;
const int N=1e6+10;

int h[N],ne[N],to[N],w[N],idx;
int a[N];
int pre[N];
int dist[N];
int cnt[N];
int vis[N];
int people[N];
void add(int x,int y,int z)
{
	ne[idx]=h[x];
	to[idx]=y;
	w[idx]=z;
	h[x]=idx++;
}
void dijkstra(int s)
{
	memset(dist,0x3f3f,sizeof(dist));
	dist[s]=0;
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> q;
	
	q.push({0,s});
	cnt[s]=1;
	people[s]=a[s];
	while(q.size())
	{
		int u=q.top().second;
		q.pop();
		if(vis[u])
			continue;
		vis[u]=1;
		for(int i=h[u];~i;i=ne[i])
		{
			int j=to[i];
			if(dist[j]>dist[u]+w[i])
			{
				people[j]=people[u]+a[j];
				dist[j]=dist[u]+w[i];
				cnt[j]=cnt[u];
				pre[j]=u;
				q.push({dist[j],j});
			}
			else if(dist[j]==dist[u]+w[i])
			{
				cnt[j]+=cnt[u];
				if(people[j]<people[u]+a[j])
				{
					people[j]=people[u]+a[j];
					pre[j]=u;
					
				}
			}
		}
	}
}
int main()
{
	int n,m,s,d;
	cin>>n>>m>>s>>d;
	memset(h,-1,sizeof(h));
	memset(pre,-1,sizeof(pre));
	for(int i=0;i<n;i++)
		cin>>a[i];
	for(int i=0;i<m;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		add(x,y,z);
		add(y,x,z);
	}
	
	dijkstra(s);
	cout<<cnt[d]<<' '<<people[d]<<endl;
	vector<int> path;
	path.push_back(d);
	while(pre[d]!=-1)
	{
		path.push_back(pre[d]);
		d=pre[d];
	}
	for(int i=path.size()-1;i>=0;i--)
	{
		if(i==path.size()-1)
			cout<<path[i];
		else
			cout<<' '<<path[i];
	}
	return 0;
}
//5
